package com.eckey.lab.consumer.controller;

import com.alibaba.fastjson.JSON;
import com.eckey.lab.common.Result;
import com.eckey.lab.consumer.bean.UserVO;
import com.eckey.lab.consumer.service.DubboConsumerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: ChengLiang
 * @CreateTime: 2023-11-13  11:03
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/consumer")
public class DubboConsumerController {

    @Autowired
    private DubboConsumerService dubboConsumerService;

    @PostMapping("/add")
    public Result add(@RequestBody UserVO user) {
        log.info("添加用户信息：{}", JSON.toJSONString(user));
        return dubboConsumerService.insert(user);
    }

    @GetMapping("/queryById/{id}")
    public Result queryById(@PathVariable("id") Integer id) {
        return dubboConsumerService.selectByKeyId(id);
    }

}
